package liumengbaio.lolzhangyoubao.Activity.Activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;

import java.util.ArrayList;
import java.util.List;

import liumengbaio.lolzhangyoubao.Activity.Adapter.ViewPagerAdapter;
import liumengbaio.lolzhangyoubao.Activity.Fragment.ComunityFragmentPlay;
import liumengbaio.lolzhangyoubao.Activity.Fragment.ComunityFragmentRealFind;
import liumengbaio.lolzhangyoubao.Activity.Fragment.ComunityFragmentRealShow;
import liumengbaio.lolzhangyoubao.R;

/**
 * Created by lanouhn on 16/9/9.
 */
public class ComunityAvtivity extends AppCompatActivity implements View.OnClickListener {
    private Button head_left_title;
    private List<String> tabNames;
    private List<Fragment> lists;
    private ViewPagerAdapter adapter;
    private TabLayout comunity_tablayout;
    private ViewPager comunity_viewpager;
    private ComunityFragmentRealShow real_show;
    private ComunityFragmentPlay play;
    private ComunityFragmentRealFind find;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.comunity_activity);
        initView();
        initData();
    }

    private void initData() {
        head_left_title.setOnClickListener(this);
        tabNames.add("真人秀");
        tabNames.add("晒玩法");
        tabNames.add("找战友");
        lists.add(real_show);
        lists.add(play);
        lists.add(find);
        adapter=new ViewPagerAdapter(getSupportFragmentManager(),tabNames,lists);
        comunity_viewpager.setAdapter(adapter);
        comunity_tablayout.setupWithViewPager(comunity_viewpager);
    }

    private void initView() {
        head_left_title = (Button) findViewById(R.id.head_left_title);
        comunity_tablayout= (TabLayout) findViewById(R.id.comunity_tablayout);
        comunity_viewpager= (ViewPager) findViewById(R.id.comunity_viewpager);
        real_show=new ComunityFragmentRealShow();
        play=new ComunityFragmentPlay();
        find=new ComunityFragmentRealFind();
        tabNames=new ArrayList<>();
        lists=new ArrayList<>();
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.head_left_title:
                finish();
                break;
        }
    }
}
